//
// Created by Semir on 2020/6/6.
//

#include <iostream>
#include <set>
#include <vector>

/*
 * 输入一个递增排序的数组和一个数字S，在数组中查找两个数，使得他们的和正好是S，
 * 如果有多对数字的和等于S，输出两个数的乘积最小的
 */

using namespace std;

vector<int> FindNumbersWithSum(vector<int> array, int sum) {
    int index1 = 0;
    int index2= array.size() - 1;
    while (index1 <= index2 && array[index1] + array[index2] != sum) {
        if (array[index1] + array[index2] < sum) {
            index1++;
        } else {
            index2--;
        }
    }
    vector<int> res(0);
    if (index1 <= index2) {
        res.emplace_back(array[index1]);
        res.emplace_back(array[index2]);
    }
    return res;
}

int main() {
    vector<int> array = {1,2,3,4,5,6,7,8,9,10};
    vector<int> res = FindNumbersWithSum(array, 12);
    cout << res.size() << endl;
    return 0;
}